package ua.kratik.seabattle.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

import ua.kratik.seabattle.dao.DataObject;

@Entity
@Table(name="battles")
public class Battle implements DataObject {
	
	@Id
	@GeneratedValue
	@Column(name = "id")
	private Integer id;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	@JoinColumn(name = "battleRules_id")
	private BattleRules battleRules;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	@JoinColumn(name = "admiral1_id")
	private User user1;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	@JoinColumn(name = "admiral2_id")
	private User user2;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	@JoinColumn(name = "layoutType1_id")
	private LayoutType layoutType1;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	@JoinColumn(name = "layoutType2_id")
	private LayoutType layoutType2;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = true)
	@JoinColumn(name = "winner_id")
	private User winner;
	
	@Column(name = "startDT")
	@DateTimeFormat(iso = ISO.DATE_TIME)
	private Date startDT;
	
	@Column(name = "endDT")
	@DateTimeFormat(iso = ISO.DATE_TIME)
	private Date endDT;
	
	@Column(name = "notes")
	private String notes;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public BattleRules getBattleRules() {
		return battleRules;
	}

	public void setBattleRules(BattleRules battleRules) {
		this.battleRules = battleRules;
	}

	public User getUser1() {
		return user1;
	}

	public void setUser1(User user1) {
		this.user1 = user1;
	}

	public User getUser2() {
		return user2;
	}

	public void setUser2(User user2) {
		this.user2 = user2;
	}

	public LayoutType getLayoutType1() {
		return layoutType1;
	}

	public void setLayoutType1(LayoutType layoutType1) {
		this.layoutType1 = layoutType1;
	}

	public LayoutType getLayoutType2() {
		return layoutType2;
	}

	public void setLayoutType2(LayoutType layoutType2) {
		this.layoutType2 = layoutType2;
	}

	public User getWinner() {
		return winner;
	}

	public void setWinner(User winner) {
		this.winner = winner;
	}

	public Date getStartDT() {
		return startDT;
	}

	public void setStartDT(Date startDT) {
		this.startDT = startDT;
	}

	public Date getEndDT() {
		return endDT;
	}

	public void setEndDT(Date endDT) {
		this.endDT = endDT;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}
	
}
